package com.cl.entity.common;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.persistence.PreUpdate;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import com.fasterxml.jackson.annotation.JsonFormat;

/*
 * 全部实体（包括资源）base entity
 */
@MappedSuperclass
public abstract class BaseEntity implements DBObject,Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Column(name="DC_EDITOR0")
	protected String dcEditor0;

	@Column(name="DC_EDITOR1")
	protected String dcEditor1;

	@Column(name="DC_EDITOR2")
	protected String dcEditor2;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="DC_CREATE")
	protected Date dcCreate;
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="LAST_UPDATE")
	protected Date lastUpdate;
	
	@Column(name="DC_STATE")
	protected String dcState; //对象状态, 草稿1（未生成稿酬记录) 正式2（已生成稿酬记录） 0 (删除)
	
	public BaseEntity()
	{
		this.dcState = "1";
	}
	
	public abstract Object getPrimaryId();
	
	/*@PrePersist
	public void prePersist()
	{
		this.lastUpdate = new Date();
		this.dcCreate = this.lastUpdate;
	}
	
	@PreUpdate
	public void preUpdate(){
		this.lastUpdate = new Date();
	}*/
	
	public void setDcEditor0(String dcEditor0)
	{
		this.dcEditor0 = dcEditor0;
	}
	
	public String getDcEditor0()
	{
		return dcEditor0;
	}
	
	public void setDcEditor1(String dcEditor1)
	{
		this.dcEditor1 = dcEditor1;
	}
	
	public String getDcEditor1()
	{
		return dcEditor1;
	}
	
	public void setDcEditor2(String dcEditor2)
	{
		this.dcEditor2 = dcEditor2;
	}
	
	public String getDcEditor2()
	{
		return dcEditor2;
	}
	
	public void setDcCreate(Date dcCreate)
	{
		this.dcCreate = dcCreate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getDcCreate()
	{
		return dcCreate;
	}
	
	public void setLastUpdate(Date lastUpdate)
	{
		this.lastUpdate = lastUpdate;
	}
	
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	public Date getLastUpdate()
	{
		return lastUpdate;
	}
	
	public void setDcState(String dcState)
	{
		this.dcState = dcState;
	}
	
	public String getDcState()
	{
		return dcState;
	}

}
